<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/axios.min.js"></script>
</head>
<body>
<button id="btn1">GET请求</button>
<button id="btn2">POST请求</button>
<button id="btn3">PUT请求</button>
<button id="btn4">DELETE请求</button>
</body>
<script>
    var btn1 = document.getElementById('btn1');
    btn1.onclick = function () {
        axios({
            url: 'user/t1/1',
            method: 'get',
            //data: objData,
            resultType: 'json'
        }).then(response => {
            console.log(response.data);
        }).catch(error => {
            console.log(error)
        })
    }

    var btn2 = document.getElementById('btn2');
    var user1 = {id: 1, name: '张三', sex: 1}
    btn2.onclick = function () {
        axios({
            url: 'user/t1',
            method: 'post',
            data: user1,
            resultType: 'json'
        }).then(response => {
            console.log(response.data);
        }).catch(error => {
            console.log(error)
        })
    }

    var btn3 = document.getElementById('btn3');
    var user2 = {id: 1, name: '张三2', sex: 2, birthday: '2024-05-20'}
    btn3.onclick = function () {
        axios({
            url: 'user/t1',
            method: 'put',
            data: user2,
            resultType: 'json'
        }).then(response => {
            console.log(response.data);
        }).catch(error => {
            console.log(error)
        })
    }

    var btn4 = document.getElementById('btn4');
    btn4.onclick = function () {
        axios({
            url: 'user/t1/1',
            method: 'delete',
            //data: user2,
            resultType: 'json'
        }).then(response => {
            console.log(response.data);
        }).catch(error => {
            console.log(error)
        })
    }

</script>
</html>